import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Collection;
import java.util.List;

/**
 * The class provides functionalities for file I/O
 * 
 */
public abstract class FileManager {
	private File file;

	/**
	 * Constructs a new FileManager object with the value of the passed in
	 * parameters
	 * 
	 * @param fileName
	 *            - the name of the file to operate on
	 */
	public FileManager(String fileName) {
		file = new File(fileName);
	}

	/**
	 * Return the file the FileManager operates on
	 * 
	 * @return the value of attribute file
	 */
	public File getFile() {
		return file;
	}

	/**
	 * Set the file the FileManager operates on to a new value
	 * 
	 * @param file
	 */
	public void setFile(File file) {
		this.file = file;
	}

	/**
	 * Create a file with the specified file name
	 * 
	 */
	public void createFile() throws IOException, Exception {
		try {
			this.file.createNewFile();
		} catch (IOException ioe) {
			throw ioe;
		} catch (Exception e) {
			throw e;
		}
	}

	/**
	 * Saving the passed in object into a file
	 * 
	 * @param fileName
	 *            - file name of the file to save to
	 * @param objects
	 *            - the objects to save
	 */
	public abstract void saveData(Collection objects) throws Exception;

	/**
	 * Retrieve data from a file and return it as an object
	 * 
	 * @param fileName
	 *            - file name of the file to load data from
	 * @param numberOfObjectToRead
	 *            - the number of object to load
	 */
	public abstract List loadData() throws Exception;
}
